﻿
using System.Linq;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class 速度控制 : MonoBehaviour
{
    float deltaTime = 0.0f;

    int x = 0;
    float 累计时间 = 0;


    private void Start()
    {
        Screen.SetResolution(720, 1280, true);
       // Application.targetFrameRate = 20;
    }

    void Update()
    {
        deltaTime += (Time.deltaTime - deltaTime) * 0.1f;

        x++;
        累计时间 += Time.deltaTime;

    }

    void OnGUI()
    {
        int w = Screen.width, h = Screen.height;

        GUIStyle style = new GUIStyle();
        Rect rect = new Rect(0, 0, w, h * 10 / 100);
        style.alignment = TextAnchor.UpperLeft;
        style.fontSize = h * 5/ 100;
        style.normal.textColor = new Color(0.2f, 0.8f, 0.0f, 1.0f);
        float msec = deltaTime * 1000.0f;
        float fps = 1.0f / deltaTime;
        string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
        //GUI.Label(rect,  Mathf.Round( fps).ToString(), style);
    }


}